package org.wdcode.back.tag.ui;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

import org.apache.struts2.views.jsp.ui.ActionErrorTag;
import org.apache.struts2.views.jsp.ui.ActionMessageTag;
import org.apache.struts2.views.jsp.ui.FieldErrorTag;

/**
 * 输出提示信息
 * @author WD
 * @since JDK6
 * @version 1.0 2010-03-26
 */
public final class MessageTag extends TagSupport {
	// 序列化ID
	private static final long	serialVersionUID	= -7382294189792893615L;
	// ActionMessage
	private ActionMessageTag	actionMessageTag;
	// FieldError
	private FieldErrorTag		fieldErrorTag;
	// ActionError
	private ActionErrorTag		actionErrorTag;

	/**
	 * 标签结束
	 */
	@Override
	public int doEndTag() throws JspException {
		// 调用标签方法
		actionMessageTag.doEndTag();
		fieldErrorTag.doEndTag();
		actionErrorTag.doEndTag();

		// 返回到页面
		return EVAL_PAGE;
	}

	/**
	 * 标签开始
	 */
	@Override
	public int doStartTag() throws JspException {
		// 初始化标签
		actionMessageTag = new ActionMessageTag();
		fieldErrorTag = new FieldErrorTag();
		actionErrorTag = new ActionErrorTag();

		// 设置PageContext
		actionMessageTag.setPageContext(pageContext);
		fieldErrorTag.setPageContext(pageContext);
		actionErrorTag.setPageContext(pageContext);

		// 调用标签方法
		actionMessageTag.doStartTag();
		fieldErrorTag.doStartTag();
		actionErrorTag.doStartTag();

		// 返回到结束
		return SKIP_BODY;
	}
}
